#!/bin/sh

mdm_list=(M_SUM_GOLD_STAT_INST
M_SUM_GOLD_STAT_PROD
M_SUM_GOLD_STAT_TRAD
M_SUM_GOLD_CALM_STAT)
ldm_list=(F_NIN_ST_TFUNDBOOK
F_NIN_ST_TR_BUY_SALE)

pardate=$1

branch_name=(110
120
212
310
330
350
351
440
442
510
500
650
130
140
150
210
220
230
320
322
331
340
360
370
371
410
420
422
430
450
460
530
520
610
620
630
640
540)

for branch3 in ${branch_name[*]}
do
	for ldm in ${ldm_list[*]}
    do
        psnow=`ps -ef|grep FileTran|grep -v vim|grep -v "grep FileTran"|wc -l`
        while true
        do
        if(($psnow>10))
        then
            sleep 10
        else
            nohup sh once_tran.sh ${branch3} $HOME/file/output/ldm_nin/ccbss/${branch3}/${pardate}/LDM_NIN_CCBSS_${ldm}_${branch3}_${pardate}.dat.gz $HOME/file/input/ccbss/${pardate}_init/LDM_NIN_CCBSS_${ldm}_${branch3}_${pardate}.dat.gz ${ldm} >>tmp_tran & 2>&1
        break
        fi
		done
    done
    for mdm in ${mdm_list[*]}
    do
        psnow=`ps -ef|grep FileTran|grep -v vim|grep -v "grep FileTran"|wc -l`
        while true
        do
        if(($psnow>10))
        then
            sleep 10
        else
            nohup sh once_tran.sh ${branch3} $HOME/file/output/mdm/${branch3}/${pardate}/MDM_CCBSS_${mdm}_${pardate}_${branch3}.dat.gz $HOME/file/input/ccbss/${pardate}_init/MDM_CCBSS_${mdm}_${pardate}_${branch3}.dat.gz ${mdm} >>tmp_tran & 2>&1
        break
        fi
		done
    done
nohup sh once_tran.sh ${branch3} $HOME/file/output/mdm/${pardate}/MDM_CCBSS_M_SUM_GOLD_PRICE_STAT_${pardate}.dat.gz $HOME/file/input/ccbss/${pardate}_init/MDM_CCBSS_M_SUM_GOLD_PRICE_STAT_${pardate}.dat.gz M_SUM_GOLD_PRICE_STAT >>tmp_tran & 2>&1

done
